﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StuLib
{
    public class Students
    {
        Dictionary<string, Student> dicStus = new Dictionary<string, Student>();

        public Student this[string sno]
        {
            get
            {
                return dicStus[sno];
            }
            set
            {
                if (value == null)
                    dicStus.Remove(sno);
                else
                    dicStus[sno] = value;
            }
        }

        public List<Student> this[string sname, int flag]
        {
            get
            {
                List<Student> lstStu = new List<Student>();
                foreach (Student s in dicStus.Values)
                {
                    if (s.SName == sname)
                        lstStu.Add(s);
                }
                return lstStu;
            }
        }

        public List<string> Snoes
        {
            get
            {
                return dicStus.Keys.ToList();
            }
        }
    }

    public class Student
    {
        public Student()
        {
        }

        public Student(string sname, string sno, int age)
        {
            SName = sname;
            Sno = sno;
            Age = age;
        }

        public string SName
        {
            get;
            set;
        }

        public string Sno
        {
            get;
            set;
        }

        public int Age
        {
            get;
            set;
        }

        public string HelloMsg
        {
            get
            {
                string fmt = "我是：{0}, 学号：{1}， 今年{2}岁";
                return string.Format(fmt, SName, Sno, Age);
            }
        }
    }
}
